package com.buanalintas.sandals.pos.position;

import com.buanalintas.bynga.Dictionary;
import com.buanalintas.bynga.Field;
import com.buanalintas.bynga.Page;
import com.buanalintas.sandals.pos.entities.PosMasterPosition;

public class Position extends Page {

    private Field positionId;
    private Field positionName;

    public Position() {
        setTheClass(PosMasterPosition.class);

        positionId = new Field();
        positionId.setName("positionId");
        positionId.setCaption("id");
        positionId.setListProperties(" align=\"right\" width=\"5%\" nowrap");
        positionId.setInputProperties(" size=\"20\"");
        getFields().add(positionId);

        positionName = new Field();
        positionName.setName("positionName");
        positionName.setCaption("name");
        positionName.setListProperties(" align=\"left\" width=\"95%\" nowrap");
        positionName.setInputProperties("");
        positionName.setInputCase(Field.CASE_UPPER);
        getFields().add(positionName);

        fillFields();

        getFieldsUnique().add(new Field[]{positionName});
        getFieldsAdd().remove(positionId);
        getFieldsEdit().remove(positionId);
        getFieldsList().remove(positionId);

        setExportList(getClass().getResourceAsStream("PositionList.jasper"));
        setExport(getClass().getResourceAsStream("Position.jasper"));
        getController().setOrder(positionName);
    }

    @Override
    public void beforeView() {
        beforeList();
    }

    @Override
    public void beforeExport() {
        getExportParams().put("title", Dictionary.getValue(this, "Position"));
    }

    @Override
    public void beforeExportMulti() {
        beforeExport();
    }
}
